Namespacing everything to /UVa.
[andmenj-acm.git] / UVa / 11508 - Life on Mars? / life.cpp
blob745fdfd5e0e53e1572311ea2636caadc21975697
1 /*
2 Problem: C -Life on Mars?
3 Author: Andrés Mejía-Posada
4 (http://blogaritmo.factorcomun.org)
6 Accepted
7 */
9 using namespace std;
10 #include <algorithm>
11 #include <iostream>
12 #include <iterator>
13 #include <sstream>
14 #include <fstream>
15 #include <cassert>
16 #include <climits>
17 #include <cstdlib>
18 #include <cstring>
19 #include <string>
20 #include <cstdio>
21 #include <vector>
22 #include <cmath>
23 #include <queue>
24 #include <deque>
25 #include <stack>
26 #include <map>
27 #include <set>
29 #define D(x) cout << #x " is " << x << endl
31 int main(){
32 //assert(freopen("life.in", "r", stdin) != NULL);
33 string line;
34 while (getline(cin, line) && line != "0"){
35 vector<int> s;
36 int x, n;
37 stringstream sin(line);
38 while (sin >> x) s.push_back(x);
39 n = s.size();
40 bool valid = true;
41 vector<int> t(n, -1);
42 for (int i=0; i<n; ++i){
43 if (s[i] >= n){
44 cout << "Message hacked by the Martians!!!\n";
45 valid = false;
48 if (valid){
49 for (int i=0; i<s.size(); ++i){
50 if (t[s[i]] == -1){
51 t[s[i]] = s[i];
52 s.erase(s.begin() + i);
53 --i;
56 for (int i=0; i<n; ++i){
57 if (t[i] != -1) cout << (i>0?" ":"") << t[i];
58 else (cout << (i>0?" ":"") << s[0]), s.erase(s.begin());
60 cout << endl;
63 return 0;